home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / test / testXpkMasterPrefsSem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-02  |  3.3 KB  |  133 lines

  1. #define NAME     "testXpkMasterPrefsSem"
  2. #define REVISION "6"
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        testXpkMasterPrefsSem
  7.     Author:        SDI
  8.     Distribution:    PD
  9.     Description:    tests "« XpkMasterPrefs »" Semaphore work
  10.     Compileropts:    -
  11.     Linkeropts:    -
  12.  
  13.  1.0   25.12.96 : first Version
  14.  1.1   26.12.96 : xpkprefs.h changed nearly totally
  15.  1.2   27.12.96 : reduced length of Forbid()/Permit()
  16.  1.3   28.02.97 : semaphore style changed
  17.  1.4   01.03.97 : XpkMainPrefs changed a bit
  18.  1.5   24.03.97 : error fix
  19.  1.6   02.04.97 : changed the XpkTypeData structure
  20. */
  21.  
  22. #include <pragma/exec_lib.h>
  23. #include <pragma/dos_lib.h>
  24. #include <exec/memory.h>
  25. #include "SDI_defines.h"
  26. #include "PrintFlags.c"
  27. #include <xpk/xpkprefs.h>
  28.  
  29. /* This is a XpkMasterPrefs private structure !!!!! */
  30.  
  31. struct XpkTypeNode {
  32.   struct Node        xtn_Node;
  33.   ULONG            xtn_Size;
  34.   struct XpkTypePrefs    xtn_TypePrefs;
  35. };
  36.  
  37. void WriteXpkTypeData(struct XpkTypeData *xp)
  38. {
  39.   STRPTR a = 0;
  40.  
  41.   PutStr("xtd_Flags     : ");
  42.   {
  43.     ULONG i = xp->xtd_Flags;
  44.     PrintFlag(&i, XTD_NoPack,      "XTD_NoPack");
  45.     PrintFlag(&i, XTD_ReturnError, "XTD_ReturnError");
  46.     PrintEndFlag(i, xp->xtd_Flags);
  47.   }
  48.   a = (STRPTR) &xp->xtd_StdID;
  49.   VPrintf("xtd_StdID     : %lx", a);
  50.   VPrintf(" (%.4s)\n", &a);
  51.   VPrintf(
  52.   "xtd_ChunkSize : %ld\n"
  53.   "xtd_Mode      : %d\n"
  54.   "xtd_Version   : %d\n"
  55.   "xtd_Password  : %s\n", &xp->xtd_ChunkSize);
  56. }
  57.  
  58. void WriteXpkTypePrefs(struct XpkTypePrefs *xp)
  59. {
  60.   PutStr("xtp_Flags       : ");
  61.   {
  62.     ULONG i = xp->xtp_Flags;
  63.     PrintFlag(&i, XPKT_NamePattern, "XPKT_NamePattern");
  64.     PrintFlag(&i, XPKT_FilePattern, "XPKT_FilePattern");
  65.     PrintEndFlag(i, xp->xtp_Flags);
  66.   }
  67.   VPrintf(
  68.     "xtp_TypeName    : %s\n"
  69.     "xtp_NamePattern : %s\n"
  70.     "xtp_FilePattern : %s\n"
  71.     "xtp_PackerData  :\n", &xp->xtp_TypeName);
  72.   WriteXpkTypeData(xp->xtp_PackerData);
  73. }
  74.  
  75. void WriteXpkMainPrefs(struct XpkMainPrefs *xp)
  76. {
  77.   VPrintf("xmp_Version     : %ld\n", &xp->xmp_Version);
  78.   PutStr("xmp_Flags       : ");
  79.   {
  80.     ULONG i = xp->xmp_Flags;
  81.     PrintFlag(&i, XPKM_UseXFD, "XPKM_UseXFD");
  82.     PrintFlag(&i, XPKM_AutoPassword, "XPKM_AutoPassword");
  83.     PrintFlag(&i, XPKM_UseExternals, "XPKM_UseExternals");
  84.     PrintEndFlag(i, xp->xmp_Flags);
  85.   }
  86.   PutStr("xmp_DefaultType :\n");
  87.   WriteXpkTypeData(xp->xmp_DefaultType);
  88.   VPrintf("xmp_Timeout     : %d\n", &xp->xmp_Timeout);
  89. }
  90.  
  91. ULONG main(void)
  92. {
  93.   struct XpkPrefsSemaphore *sem;
  94.  
  95.   Forbid();
  96.   if((sem = (struct XpkPrefsSemaphore *) FindSemaphore(XPKPREFSSEMNAME)))
  97.     ObtainSemaphoreShared((struct SignalSemaphore *) sem);
  98.   Permit();
  99.  
  100.   if(sem)
  101.   {
  102.     VPrintf("xps_Version       : %ld\n", &sem->xps_Version);
  103.     {
  104.       STRPTR b;
  105.       b = (STRPTR) &sem->xps_PrefsType;
  106.       VPrintf("xps_PrefsType     : %lx", b);
  107.       VPrintf(" (%.4s)\n", &b);
  108.     }
  109.     VPrintf("xps_RecogSize     : %ld\n", &sem->xps_RecogSize);
  110.  
  111.     if(sem->xps_MainPrefs)
  112.     {
  113.       WriteXpkMainPrefs(sem->xps_MainPrefs);
  114.       PutStr("\n");
  115.     }
  116.  
  117.     if(sem->xps_PrefsType == XPREFSTYPE_STANDARD)
  118.     {
  119.       struct Node *n;
  120.       n = ((struct List *) sem->xps_PrefsData)->lh_Head;
  121.  
  122.       for(;n->ln_Succ && !CTRL_C; n = n->ln_Succ)
  123.       {
  124.         WriteXpkTypePrefs(&((struct XpkTypeNode *) n)->xtn_TypePrefs);
  125.         PutStr("\n");
  126.       }
  127.     }
  128.     ReleaseSemaphore((struct SignalSemaphore *) sem);
  129.   }
  130.   else
  131.     PutStr(XPKPREFSSEMNAME " Semaphore not found.\n");
  132. }
  133.